from SessionEndTime import SessionEndTime


class Session:
    __endTime: SessionEndTime
    __startTime: int
    __maxDuration: int

    @property
    def endTime(self) -> SessionEndTime:
        return self.__endTime

    @property
    def startTime(self) -> int:
        return self.__startTime

    @property
    def maxDuration(self) -> int:
        return self.__maxDuration

    @property
    def minDuration(self) -> int:
        return self.__minDuration

    def __init__(self, start_time, end_time: SessionEndTime):
        self.__startTime = start_time
        self.__endTime = end_time
        self.__minDuration = (end_time.earliestHour - start_time) * 60
        self.__maxDuration = (end_time.latestHour - start_time) * 60

    def printTalks(self, talks: list) -> list:
        import time
        date_str = '2018-10-21 %s:00' % self.startTime
        start_interval = int(time.mktime(time.strptime(date_str, "%Y-%m-%d %H:%M")))
        talks = [] + talks
        prints = []
        for talk in talks:
            time_local = time.localtime(start_interval)
            a_print = time.strftime("%I:%M%p", time_local) + ' ' + talk.content
            start_interval += talk.duration * 60
            prints.append(a_print)
            print(a_print)

        time_local = time.localtime(start_interval)
        a_print = time.strftime("%I:%M%p", time_local) + ' '
        prints.append(a_print)
        return prints

